package com.qinggeng.project.api.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.qinggeng.common.enums.GoodsTypeEnum;
import com.qinggeng.common.utils.DateUtils;
import com.qinggeng.project.system.domain.GoodsMark;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
@Slf4j
@ApiModel("商品列表")
public class GoodsDto {

    //商品ID
    @ApiModelProperty(value = "商品id",required = true )
    private Long goodsId;

    //商品名称
    @ApiModelProperty(value = "商品名称",required = true )
    private String goodsName;

    //商品图片
    @ApiModelProperty(value = "商品图片",required = true )
    private String goodsImg;

    //商品长图
    @ApiModelProperty(value = "商品长图",required = true )
    private String goodsLongImg;

    //商品价格
    @ApiModelProperty(value = "商品价格",required = true )
    private BigDecimal goodsPrice;

    //划线价格
    @ApiModelProperty(value = "划线价格",required = true )
    private BigDecimal linePrice;

    //拼团价格
    @ApiModelProperty(value = "拼团价格",required = true )
    private BigDecimal groupPrice;

    //补贴价格
    @ApiModelProperty(value = "补贴价格",required = true )
    private String reducePrice;

    //商户ID
    @ApiModelProperty(value = "商户ID",required = true )
    private Long shopId;

    //属性
    @ApiModelProperty(value = "属性",required = true )
    private String attributes;

    //属性名
    @ApiModelProperty(value = "属性名",required = true )
    private String attributesName;

    //商品主类
    @ApiModelProperty(value = "商品主类",required = true )
    private Long mainCategory;

    //库存
    @ApiModelProperty(value = "库存",required = true )
    private Integer keepNum;

    //销量
    @ApiModelProperty(value = "销量",required = true )
    private Integer saleNum;

    @ApiModelProperty(value = "购物车内数量",required = true )
    private Integer cartNum;

    @ApiModelProperty(value = "购物车id",required = true )
    private Long cartId;

    //商品标签
    @ApiModelProperty(value = "商品标签",required = true )
    private String goodsMark;

    //商品标签
    @ApiModelProperty(value = "商品标签",required = true )
    private List<GoodsMark> goodsMarkList;

    //商品短视频
    @ApiModelProperty(value = "商品短视频",required = true )
    private String goodsVideo;

    //同城优惠百分比
    @ApiModelProperty(value = "同城优惠百分比",required = true )
    private String proportion;

    //商品提成百分比
    @ApiModelProperty(value = "商品提成百分比",required = true )
    @JsonIgnore
    private String percent;

    //商品进价
    @ApiModelProperty(value = "商品进价",required = true )

    private BigDecimal buyPrice;

    //此商品当天是否捶过
    @ApiModelProperty(value = "此商品当天是否捶过",required = true )
    private Boolean isBeat = false;
    //商品类型
    private String goodsType;

    //供应商
    private String supplier;

    //供应商推荐描述
    @JsonIgnore
    private String supplierDesc;
    //单位
    private String lowNum;
    //规格
    private String spec;
    //人气
    private String popularity;

    private String wantValue;
    //背景颜色
    private String color;

    //预售
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date startDate;

    private String startDateStamp;
    //提货时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date pickDate;

    private String pickDateStamp;

    //预计送达时间
    private String distTime;

    //平台保障
    private String guarantee;


    //售后信息
    private String afterSaleInformation;

    private String top;

    private Integer sort;
    //分享标题
    private String title;
    //分享副标题
    private String subtitle;

    //商品提成
    private BigDecimal percentage;

    //批发商品id  0表示没有绑定批发商品
    private Long wholeGoodsId;

    //会员价
    private String vipPrice;


    public String getDistTime() {
        if(this.getGoodsType().equals(GoodsTypeEnum.预售商品.getValue())){
            if(null==this.pickDate){
                return "";
            }
            try{
                return DateUtils.parseDateToStr("MM月dd日 HH:mm:ss",this.pickDate);
            }catch (Exception e){
                return "";
            }
        }
        return distTime;
    }

    public String getSupplier() {
        return this.supplier+this.supplierDesc;
    }



}
